﻿// Author: AustralTek 
// Create date: 2010/05/04
// http://www.australtek.com
// Copyright: 2009 - 2010

(function () {
    function _DisplayPoster(object, options) {
        try {
            //private members
            var privateParameters;
            var background;
            var img;
            var logo;
            var legend;
            var container;

            function _initialize(myDiv, options) {
                try {
                    privateParameters = new PrivateParameters(options);
                    privateParameters.Version.Class = 'DisplayPoster';
                    /******************************************************/
                    ////        Types:
                    ////        Generic Float:      0;            
                    ////        Absolute:           1;
                    ////        Relative:           2;                           
                    ////        Float:              3;
                    ////        IndustrialGrid relative:  4;
                    ////        In middle of the screen: 5;
                    ////        none (just a simple container): 6;

                    container = myDiv;
                    container.className = 'DiplayPoster';
                    var center = document.createElement('center');
                    background = document.createElement("div");
                    center.appendChild(background);
                    background.className = 'loadingBackground';
                    background.style.width = '300px';
                    background.style.height = '57px';

                    logo = document.createElement('div');
                    logo.style.width = '100%';
                    logo.style.height = '50%';

                    img = document.createElement("div");
                    img.style.width = '40px';
                    img.style.height = '40px';
                    img.style.marginTop = '8px';
                    img.style.zIndex = '1';

                    legend = document.createElement("div");
                    legend.style.fontFamily = 'Microsoft Sans Serif, Tahoma';
                    legend.style.fontSize = '14px';
                    legend.style.fontWeight = 'normal';
                    legend.style.color = '#6E6E88';
                    legend.style.zIndex = '0';
                    legend.style.position = 'absolute';
                    img.style.marginLeft = '90px';
                    legend.style.marginTop = '20px';
                    legend.style.marginLeft = '140px';
                    legend.innerHTML = privateParameters.Title;
                    var offWidth = window.document.body.offsetWidth;
                    if (offWidth <= 0) offWidth = window.screen.width - 32;

                    switch (privateParameters.Type) {
                        case 0: //Generic Float
                            background.style.marginTop = '0px';
                            break;

                        case 1: //Absolute
                            img.style.marginLeft = '10px';
                            img.style.background = 'transparent';
                            legend.style.marginTop = '20px';
                            legend.style.marginLeft = '140px';
                            background.style.top = '275px';
                            background.style.position = 'absolute';
                            break;
                        case 2: //Relative
                            img.style.marginLeft = '40px';
                            img.style.background = 'transparent';
                            legend.style.marginTop = '20px';
                            legend.style.marginLeft = '25px';
                            background.style.top = '10px';
                            background.style.position = 'relative';
                            break;
                        case 3: //Float
                            background.style.marginTop = '35px';
                            break;
                        case 4: //IndustrialGird relative
                            background.style.marginTop = '0px';
                            break;
                        case 5: //In middle of the screen
                            img.style.marginLeft = '10px';
                            img.style.background = 'transparent';
                            legend.style.marginTop = '20px';
                            legend.style.marginLeft = '140px';
                            background.style.top = (window.document.body.clientHeight - 75) / 2 + 'px';
                            background.style.position = 'absolute';
                            break;
                        case 6: //none - managed with the container.
                            background.style.position = "relative";
                            img.style.position = "absolute";
                            legend.style.position = "absolute";
                            img.style.left = "-10px";
                            legend.style.top = "0px";
                            legend.style.left = "-5px";
                            break;
                    }
                    if ((privateParameters.Animate != undefined) && (privateParameters.Animate == true)) {
                        img.className = 'loadingGif';
                        img.style.marginLeft = '90px';
                        legend.style.marginLeft = '140px';
                    } else {
                        img.className = 'noDataGif';
                        img.style.marginLeft = '70px';
                        legend.style.marginLeft = '120px';
                    }
                    img.style.position = 'absolute';
                    logo.appendChild(img);
                    background.appendChild(legend);
                    background.appendChild(logo);
                    container.appendChild(center);
                    /******************************************************/
                } catch (Error) { privateParameters.Events.onError(Error); }
            }
            _initialize(object, options);

            function _getControl() {
                try {
                    return background;
                } catch (Error) { privateParameters.Events.onError(Error); }
            }

            function _setVisible(visible) {
                try {
                    if (visible) //IE does not hidde the image, FF works fine.
                    {
                        background.style.display = '';
                        if (privateParameters.Animate) img.className = 'loadingGif';
                        else img.className = 'noDataGif';
                        img.style.display = '';
                        logo.style.display = '';
                        legend.style.display = '';
                    }
                    else {
                        background.style.display = 'none';
                        img.className = 'emptyGif';
                        img.style.display = 'none';
                        logo.style.display = 'none';
                        legend.style.display = 'none';
                    }
                } catch (Error) { privateParameters.Events.onError(Error); }
            }

            function _setTitle(title, isAnimate) {
                try {
                    legend.innerHTML = title;
                    privateParameters.Title = title;
                    privateParameters.Animate = isAnimate;
                    if ((isAnimate != undefined) && (isAnimate)) {
                        img.className = 'loadingGif';
                        img.style.marginLeft = '90px';
                        legend.style.marginLeft = '140px';
                    } else {
                        img.className = 'noDataGif';
                        img.style.marginLeft = '70px';
                        legend.style.marginLeft = '120px';
                    }
                } catch (Error) { privateParameters.Events.onError(Error); }
            }


            function _processingDisplay() {
                try {
                    if (privateParameters.Timer != null) clearTimeout(privateParameters.Timer);
                    privateParameters.Value = 0;
                    privateParameters.Timer = setTimeout(_updateLegend, 1000);
                } catch (Error) { privateParameters.Events.onError(Error); }

            }

            function _updateLegend() {
                try {
                    legend.innerHTML = 'Processing... ' + (privateParameters.Value += 1) + 's';
                    privateParameters.Timer = setTimeout(_updateLegend, 1000);
                } catch (Error) { privateParameters.Events.onError(Error); }
            }

            function _cancelProcessingDisplay() {
                try {
                    if (privateParameters.Timer) clearTimeout(privateParameters.Timer);
                } catch (Error) { privateParameters.Events.onError(Error); }
            }

            //Public members
            this.GetControl = function () {
                return _getControl();
            }
            this.SetVisible = function (visible) {
                _setVisible(visible);
            }
            this.SetTitle = function (title, isAnimate) {
                _setTitle(title, isAnimate);
            }
            this.CancelProcessingDisplay = function () {
                _cancelProcessingDisplay();
            }

        } catch (Error) { return Error; }
    }

    window.DisplayPoster = function (object, options) { return new _DisplayPoster(object, options); }
})();
/**************************************************************************************/

function getScreenSize(attrib) {
    if (parent != null) {
        switch (attrib) {
            case 'height':
                return parent.screen.height;
                break;

            case 'width':
                return parent.screen.width;
                break;
        }
    }
}

//Parsing queryString
function PageQuery(q) {
    if (q.length > 1)
        this.q = q.substring(1, q.length);
    else
        this.q = null;

    this.keyValuePairs = new Array();
    if (q) {
        for (var i = 0; i < this.q.split("&").length; i++) {
            this.keyValuePairs[i] = this.q.split("&")[i];
        }
    }

    this.getKeyValuePairs = function () {
        return this.keyValuePairs;
    }
    this.getValue = function (s) {
        for (var j = 0; j < this.keyValuePairs.length; j++) {
            if (this.keyValuePairs[j].split("=")[0] == s)
                return this.keyValuePairs[j].split("=")[1];
        }
        return null;
    }

    this.getParameters = function () {
        var a = new Array(this.getLength());
        for (var j = 0; j < this.keyValuePairs.length; j++) {
            a[j] = this.keyValuePairs[j].split("=")[0];
        }
        return a;
    }

    this.getLength = function () {
        return this.keyValuePairs.length;
    }
}

function queryString(key) {
    var page = new PageQuery(window.location.search);
    return unescape(page.getValue(key));
}

function getItem(key) {
    //key  = key.toUpperCase();
    if (queryString(key) == 'null') {
        //item not found.
        return null;
    }
    else {
        return trim(queryString(key));
    }
}

/* **************************** Events ****************************************************** */
function addEventHandler(obj, event, delegHandler) {
    try {
        if (navigator.appName == 'Microsoft Internet Explorer') obj.attachEvent(event, delegHandler, false);
        else if ((navigator.appName == 'Netscape') || (navigator.appName == 'Opera')) {
            event = event.substring(2, event.length);
            obj.addEventListener(event, delegHandler, false);
        }
    } catch (Error) { return Error; }
}

function removeEventHandler(obj, event, delegHandler) {
    try {
        if (navigator.appName == 'Microsoft Internet Explorer') obj.detachEvent(event, delegHandler, false);
        else if ((navigator.appName == 'Netscape') || (navigator.appName == 'Opera')) {
            event = event.substring(2, event.length);
            obj.removeEventListener(event, delegHandler, false);
        }
    } catch (Error) { return Error; }
}

function attachDomReadyEventHandler(fn) {
    if (document.addEventListener)
        document.addEventListener("DOMContentLoaded", fn, false);
    else if (document.all && !window.opera) {
        document.write('<script type="text/javascript" id="contentLoadTag" defer="defer" src="javascript:void(0)"><\/script>');
        var contentLoadTag = document.getElementById("contentLoadTag");
        contentLoadTag.onreadystatechange = function () {
            if (this.readyState == "complete")
                fn();
        };
    }
}

(function () {
    function _AttachedEventsCollection() {
        try {

        } catch (Error) { }
    }
    _AttachedEventsCollection.prototype = {
        attachEvent: function (obj, event, delegHandler) {

        }
        , detachEvent: function (obj, event, delegHandler) {

        }
    }
    window.AttachedEventsCollection = function () { return new _AttachEventsCollection(); }
})();

function attachEventHandler(obj, event, delegHandler) {
    try {

    } catch (Error) { return Error; }
}

function dettachEventHandler(obj, event, delegHandler) {
    try {

    } catch (Error) { return Error; }
}

/* ///////////////////////////////////////////////////////////////////////////////////////// */

/* ////////////////////////// Prints helpers functions /////////////////////////////////////////////// */

function generateHtmlPage(strHtml) {
    var header = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/ xhtml1-transitional.dtd\">";

    header += "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head>";
    for (i = 0; i < document.styleSheets.length; i++) {
        header += "<link href=\"" + document.styleSheets[i].href;

        header += "\" rel=\"stylesheet\" type=\"text/css\" media =\"screen\"/>";
    }
    header += "</head>";
    strHtml = header + "<body>" + strHtml + "</body></html>";

    return formatToSendingHTML(strHtml);
}

function formatToSendingHTML(strHtml) {
    /*
    Replaces in the html code some characters, leaving the string in only one line,
    with the < replaced to a left pointing arrow (\u2190) and > replaced to the right
    pointing arrow (\u2192). This values are needed to then convert the string into
    html - readeble code.
    003C -> 2190
    003E -> 2192
    0022 -> \\\"
    \n -> ""
    \r -> ""
    &%13 -> ""
    &%10 -> ""
    */

    var r = /\u0022/g;
    r = /\n/g;
    strHtml = strHtml.replace(r, "");
    r = /\r/g;
    strHtml = strHtml.replace(r, "");
    r = /\u003C/g;
    strHtml = strHtml.replace(r, "\u2190");
    r = /\u003E/g;
    strHtml = strHtml.replace(r, "\u2192");
    r = /&#10;|&#13;/g;
    strHtml = strHtml.replace(r, "");
    return strHtml;
}

function getHtmlString(strhtml, height)//This should be called from the html pages to generate the object to send.
{
    return generateHtmlPage(strhtml);
}

//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////

/* ///////////////////////////////////////////////////////////////////////////////////////// */

/* ////////////////////////// FreeRefManager /////////////////////////////////////////////// */
var FreeRefManager = {
    RemoveAllChildNodes: function (parent) {
        if ((parent) && (parent.childNodes.length > 0)) {
            for (var i = parent.childNodes.length - 1; i > -1; i--) {
                var c = parent.childNodes[i];
                if ((c.childNodes) && (c.childNodes.length > 0)) this.RemoveAllChildNodes(c);
                parent.removeChild(c);
                this.ReleaseAllReference(c);
                if (c.innerHTML)
                    c.innerHTML = '';
                delete c;
                c = null;
            }
        }
    },
    ReleaseAllReference: function (obj) {
        var c, t, l, n;
        c = obj.childNodes;
        if (c) {
            l = c.length;
            for (t = 0; t < l; t++) {
                this.ReleaseAllReference(obj.childNodes[t]);
            }
        }
        c = obj.attributes;
        if (c) {
            l = c.length;
            for (t = 0; t < l; t++) {
                n = c[t].name;
                if (typeof (obj[n]) == 'function') {
                    obj[n] = null;
                }
            }
        }
    }
}

/* ///////////////////////////////////////////////////////////////// */

/* //////////////////// Time parser //////////////////////////////// */
function getDateTime(stringDate) {
    try {
        var ad = stringDate.split(',');
        //Year[0] //Month[1] //Day[2] //Hour[3] //Min[4] //Second[5] //MilliSec[6]    
        var auxDate = new Date(ad[0], ad[1] - 1, ad[2], ad[3], ad[4], ad[5], ad[6]);
        return auxDate;
    } catch (Error) { privateParameters.Events.onError(Error); return null; }

};

function timetStringd(timet) {
    try {
        var d = new Date();
        d.setTime(timet);
        s = zeropad(d.getHours()) + ":" + zeropad(d.getMinutes());
        if (d.getHours() == 1 && d.getMinutes() == 0 && d.getSeconds() == 0) {
            s += '<br/>'
            s += zeropad(d.getMonth() + 1) + '/' + zeropad(d.getDate()); //'Shift 1           
        } else if (d.getHours() == 13 && d.getMinutes() == 0 && d.getSeconds() == 0) {
            s += '<br/>'
            s += zeropad(d.getMonth() + 1) + '/' + zeropad(d.getDate()); //'Shift 2
        }
        return s;
    } catch (Error) { privateParameters.Events.onError(Error); return null; }
};

function timetStringh(timet) {
    try {
        var d = new Date();
        d.setTime(timet);
        s = zeropad(d.getHours()) + ":" + zeropad(d.getMinutes());
        return s;
    } catch (Error) { privateParameters.Events.onError(Error); return null; }
};

function zeropad(n) {
    return String("00" + n).slice(-2);
};

function completeTimeToString(time) {
    var d = new Date();
    d.setTime(time);
    s = zeropad(d.getMonth() + 1) + '/' + zeropad(d.getDate()) + ' ' + d.getHours() + ':' + zeropad(d.getMinutes());
    return s;
};
/* //////////////////////End Time parser ////////////////////////////// */

//Retrieves the value of SQL Parameter Item.
function getSQLParametersValue(value, params) {
    try {
        for (var i = 0; i < params.length; i++) {
            if (params[i].Name.toString().indexOf(value) > -1) { return params[i].Value; break; }
        }
        return null;
    } catch (Error) { return { 'Error': Error, 'value': null }; }
}
/* //////////////////////////////////////////////////////////////////// */

function getElementsByClassName(className, node) {
    try {
        if (!node) node = document.getElementsByTagName("body")[0];
        var a = []; var re = new RegExp('\\b' + className + '\\b');
        var els = node.getElementsByTagName("*");
        for (var i = 0, j = els.length; i < j; i++)
            if (re.test(els[i].className))
                a.push(els[i]);
        return a;
    } catch (Error) { return { 'Error': Error, 'value': null }; }
}

function getElementByHREFName(href, node) {
    try {
        if ((node.childNodes) && (node.childNodes.length > 0)) {
            for (var i = 0; i < node.childNodes.length; i++) {
                var elem = getElementByHREFName(href, node.childNodes[i]);
                if (elem) return elem;
            }
        } else if ((node.href) && (node.href.indexOf(href) > -1)) {
            return node;
        }
    } catch (Error) { }
}


function trim(s) {
    var l = 0; var r = s.length - 1;
    while (l < s.length && s[l] == ' ')
    { l++; }
    while (r > l && s[r] == ' ')
    { r -= 1; }
    return s.substring(l, r + 1);
}


/* /////////////////////////////////////////////////////////////////// */
//Parsing
function generateHtmlPage(strHtml) {
    //strHtml is a part of an html code. Such as a <div>..</div>, or obj.innerHTML 
    var header = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/ xhtml1-transitional.dtd\">";
    header += "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head>";
    for (i = 0; i < document.styleSheets.length; i++) {
        header += "<link href=\"" + document.styleSheets[i].href/*.replace(/\.\./g, ".")*/;
        header += "\" rel=\"stylesheet\" type=\"text/css\" media =\"screen\"/>";
    }
    header += "</head>";
    strHtml = header + "<body>" + strHtml + "</body></html>";
    return html2jSonCompatible(strHtml);
}

function html2jSonCompatible(strHtml) {
    /*
    Replaces in the html code some characters, leaving the string in only one line,
    with the < replaced to a left pointing arrow (\u2190) and > replaced to the right
    pointing arrow (\u2192). This values are needed to then convert the string into
    html - readeble code.
    003C -> 2190
    003E -> 2192
    0022 -> \\\"
    \n -> ""
    \r -> ""
    &%13 -> ""
    &%10 -> ""
    */

    var r = /\u0022/g;
    //strHtml = strHtml.replace(r, "\\\""); 
    r = /\n/g;
    strHtml = strHtml.replace(r, "");
    r = /\r/g;
    strHtml = strHtml.replace(r, "");
    r = /\u003C/g;
    strHtml = strHtml.replace(r, "\u2190");
    r = /\u003E/g;
    strHtml = strHtml.replace(r, "\u2192");
    r = /&#10;|&#13;/g;
    strHtml = strHtml.replace(r, "");
    return strHtml;
}

function getHtml2Json(strhtml, height)          //This should be called from the html pages to generate the object to send.
{
    var jSonHRMObj = new Object();
    jSonHRMObj.HTMLCode = generateHtmlPage(strhtml);
    jSonHRMObj.Height = height;
    return jSonHRMObj;
}

/* /////////////////////////////////////////////////////////////////// */

(function () {
    function _PrivateParameters(options) {
        try {
            this.URL = '../../../DALService.svc/CallProcedure'; //as default
            if (options) for (var option in options) eval('this.' + option + '=options["' + option + '"]');

            // ConnectionParamters...
            if (this.ConnectionParameters) {
                this.ConnectionParameters.Async = ((this.ConnectionParameters.Async != null) && (this.ConnectionParameters.Async != undefined)) ? this.ConnectionParameters.Async : true;
                this.ConnectionParameters.Method = this.ConnectionParameters.Method || 'POST';
            }
            else {
                this.ConnectionParameters = new Object();
                this.ConnectionParameters.Async = true;
                this.ConnectionParameters.Method = 'POST';
            }

            //DatabaseParameters or JSONFile...
            if (this.DatabaseParameters) {
                this.DatabaseParameters.DBEngine = this.DatabaseParameters.DBEngine || 'SQLServer';
                this.DatabaseParameters.ConnectionStringName = this.DatabaseParameters.ConnectionStringName || 'IndustrialDashboard';
                this.DatabaseParameters.Procedure = this.DatabaseParameters.Procedure || '';
                this.DatabaseParameters.TablesCount = this.DatabaseParameters.TablesCount || 0;

                this.JSONFile = '';
            }
            else if (this.JSONFile) {

                //                //Only method = GET is valid to use JSONFile.
                //                this.ConnectionParameters.Method = 'POST';
                //                this.ConnectionParameters.Async = true;

                this.DatabaseParameters = new Object();
                this.DatabaseParameters.DBEngine = '';
                this.DatabaseParameters.ConnectionStringName = '';
                this.DatabaseParameters.Procedure = '';
                this.DatabaseParameters.TablesCount = 0;
            }
            else {
                this.DatabaseParameters = new Object();
                this.DatabaseParameters.DBEngine = 'SQLServer';
                this.DatabaseParameters.ConnectionStringName = 'IndustrialDashboard';
                this.DatabaseParameters.Procedure = '';
                this.DatabaseParameters.TablesCount = 0;

                this.JSONFile = '';
            }

            // Events...
            if (this.Events) {
                this.Events.onError = (this.Events.onError) || (function (error) { });
                this.Events.onFailure = (this.Events.onFailure) || (function (message) { });
                this.Events.onComplete = (this.Events.onComplete) || (function () { });
                this.Events.onChange = (this.Events.onChange) || (function () { });
            } else {
                this.Events = {};
                this.Events.onError = function (error) { };
                this.Events.onFailure = function (message) { };
                this.Events.onComplete = function () { };
                this.Events.onChange = function () { };
            }

            // Version...
            this.Version = new Object();
            this.Version.Namespace = 'IndustrialDashboard';
            this.Version.Class = '';
            this.Version.info = 'ID 2.0';
            return this;
        } catch (Error) { }
    }
    window.PrivateParameters = function (options) { return new _PrivateParameters(options); }
})();

(function () {
    function _PrivateClasses(options) {
        try {
            for (var opt in options) this[opt] = options[opt]();
            return this;
        }
        catch (Error) { window.status = Error.message; return null; }
    }
    window.PrivateClasses = function (options) { return new _PrivateClasses(options); };
})();

var DatabaseConnection = {
    //DatabaseEngine
    GetDatabaseEngine: function (databaseEngine) {
        return databaseEngine;
    }
    , SetDatabaseEngine: function (privateParameters, newDatabaseEngine) {
        privateParameters.DatabaseEngine = newDatabaseEngine;
    }
    //ConnectionStringName
    , GetConnectionStringName: function (connectionStringName) {
        return connectionStringName;
    }
    , SetConnectionStringName: function (privateParameters, newConnectionStringName) {
        privateParameters.ConnectionStringName = newConnectionStringName;
    }
    //Procedure
    , GetProcedure: function (newProcedure) {
        return newProcedure;
    }
    , SetProcedure: function (privateParameters, newProcedure) {
        privateParameters.Procedure = newProcedure;
    }
    //TablesCount
    , SetTablesCount: function (tablesCount) {
        return tablesCount;
    }
    , SetTablesCount: function (privateParameters, newtablesCount) {
        privateParameters.TablesCount = newtablesCount;
    }
};

/* ////////////////////////////// ConnectionParameters /////////////////////////////////////////// */
(function () {
    function _QueryParameters(options) {
        try {
            var Parameters;
            function _initialize(options) {
                try {
                    privateParameters = new PrivateParameters(options);
                    privateParameters.DBEngine = privateParameters.DBEngine || 'SQLSERVER';
                    privateParameters.Version = { 'Class': 'SQLParameters', 'info': 'ID 2.0' };
                    Parameters = new Array();
                } catch (Error) { }
            }

            _initialize(options);

            function _add(name, type, value) {
                try {
                    var item = {}; item.Name = name; item.Type = _getDBTypeToInt(type); item.value = value; Parameters.push(item);
                } catch (Error) { }
            }
            function _getQueryParameters() { return Parameters; }
            function _getDBTypeToInt(dbType) {
                if ((dbType != undefined) && (dbType != null)) {
                    if (typeof (dbType) == 'string') {
                        dbType = dbType.replace('(SqlDbType.|OracleDbType.)', '');

                        switch (privateParameters.DBEngine.toUpperCase()) {
                            case 'SQLSERVER':
                                switch (dbType.toUpperCase()) {
                                    case 'BIGINT': dbTypeInt = 0; break;
                                    case 'BINARY': dbTypeInt = 1; break;
                                    case 'BIT': dbTypeInt = 2; break;
                                    case 'CHAR': dbTypeInt = 3; break;
                                    case 'DATETIME': dbTypeInt = 4; break;
                                    case 'DECIMAL': dbTypeInt = 5; break;
                                    case 'FLOAT': dbTypeInt = 6; break;
                                    case 'IMAGE': dbTypeInt = 7; break;
                                    case 'INT': dbTypeInt = 8; break;
                                    case 'MONEY': dbTypeInt = 9; break;
                                    case 'NCHAR': dbTypeInt = 10; break;
                                    case 'NTEXT': dbTypeInt = 11; break;
                                    case 'NVARCHAR': dbTypeInt = 12; break;
                                    case 'REAL': dbTypeInt = 13; break;
                                    case 'UNIQUEIDENTIFIER': dbTypeInt = 14; break;
                                    case 'SMALLDATETIME': dbTypeInt = 15; break;
                                    case 'SMALLINT': dbTypeInt = 16; break;
                                    case 'SMALLMONEY': dbTypeInt = 17; break;
                                    case 'TEXT': dbTypeInt = 18; break;
                                    case 'TIMESTAMP': dbTypeInt = 19; break;
                                    case 'TINYINT': dbTypeInt = 20; break;
                                    case 'VARBINARY': dbTypeInt = 21; break;
                                    case 'VARCHAR': dbTypeInt = 22; break;
                                    case 'VARIANT': dbTypeInt = 23; break;
                                    case 'XML': dbTypeInt = 25; break;
                                    case 'UDT': dbTypeInt = 29; break;
                                    case 'STRUCTURED': dbTypeInt = 30; break;
                                    case 'DATE': dbTypeInt = 31; break;
                                    case 'TIME': dbTypeInt = 32; break;
                                    case 'DATETIME2': dbTypeInt = 33; break;
                                    case 'DATETIMEOFFSET': dbTypeInt = 34; break;
                                    default: dbTypeInt = 12;
                                }
                                break;
                            case 'ORACLE':
                                switch (dbType.toUpperCase()) {
                                    case 'BFILE': dbTypeInt = 101; break;
                                    case 'BLOB': dbTypeInt = 102; break;
                                    case 'BYTE': dbTypeInt = 103; break;
                                    case 'CHAR': dbTypeInt = 104; break;
                                    case 'CLOB': dbTypeInt = 105; break;
                                    case 'DATE': dbTypeInt = 106; break;
                                    case 'DECIMAL': dbTypeInt = 107; break;
                                    case 'DOUBLE': dbTypeInt = 108; break;
                                    case 'LONG': dbTypeInt = 109; break;
                                    case 'LONGRAW': dbTypeInt = 110; break;
                                    case 'INT16': dbTypeInt = 111; break;
                                    case 'INT32': dbTypeInt = 112; break;
                                    case 'INT64': dbTypeInt = 113; break;
                                    case 'INTERVALDS': dbTypeInt = 114; break;
                                    case 'INTERVALYM': dbTypeInt = 115; break;
                                    case 'NCLOB': dbTypeInt = 116; break;
                                    case 'NCHAR': dbTypeInt = 117; break;
                                    case 'NVARCHAR2': dbTypeInt = 119; break;
                                    case 'RAW': dbTypeInt = 120; break;
                                    case 'REFCURSOR': dbTypeInt = 121; break;
                                    case 'SINGLE': dbTypeInt = 122; break;
                                    case 'TIMESTAMP': dbTypeInt = 123; break;
                                    case 'TIMESTAMPLOCALTZ': dbTypeInt = 124; break;
                                    case 'TIMESTAMPTZ': dbTypeInt = 125; break;
                                    case 'VARCHAR2': dbTypeInt = 126; break;
                                    case 'XMLTYPE': dbTypeInt = 127; break;
                                    case 'ARRAY': dbTypeInt = 128; break;
                                    case 'OBJECT': dbTypeInt = 129; break;
                                    case 'REF': dbTypeInt = 130; break;
                                    case 'BINARYDOUBLE': dbTypeInt = 1332; break;
                                    case 'BINARYFLOAT': dbTypeInt = 133; break;
                                    default: dbTypeInt = 107;
                                }
                                break;
                        }
                    }
                    else {
                        switch (privateParameters.DBEngine.toUpperCase()) {
                            case 'SQLSERVER':
                                dbTypeInt = ((dbType >= 0) && (dbType <= 34))
                                        ? dbType
                                        : 12;
                                break;
                            case 'ORACLE':
                                dbTypeInt = ((dbType >= 101) && (dbType <= 133) && (dbType != 128))
                                        ? dbType
                                        : 107;
                                break;
                        }
                    }
                }

                return dbTypeInt;
            }

            /*--------------------------*/
            /*----- Public methods -----*/
            /*--------------------------*/

            this.Add = function (name, type, value) { _add(name, type, value); }
            this.GetQueryParameters = function () { return _getQueryParameters(); }
            this.DBTypeToInt = function (DBType) { return _getDBTypeToInt(DBType); }
            this.GetDBEngine = function () { return DatabaseConnection.GetDatabaseEngine(privateParameters.DBEngine); };
            this.SetDBEngine = function (newDBEngine) { DatabaseConnection.SetDatabaseEngine(privateParameters, newDBEngine); };
            this.GetDBTypeToInt = function (DBType) { return _getDBTypeToInt(DBType); };
            this.Version = function () { return (version.Class + ' ' + version.info); };
        } catch (Error) { return Error; }
    }
    window.QueryParameters = function (instanceOptions) { return new _QueryParameters(instanceOptions); }
})();

/* //////////////////////////////////////////////////////////////////////////////////////// */

/* ////////////////////////////// Request/JSON methods //////////////////////////////////// */
function RequestJSON(url, options) {
    try {
        if (options) {//override certain properties
            options.data = (options.data) ? JSONEncode(options.data) : '';
            options.url = url;
            options.headers = (options.headers) ? options.headers : { 'Content-type': 'application/json' };
            options.method = (options.method) ? options.method : 'POST';
            options.urlEncode = (options.urlEncode != undefined) ? options.urlEncode : false;
            options.onRequest = (options.onRequest) ? options.onRequest : function doNothing() { };
            options.onSuccess = (options.onSuccess) ? options.onSuccess : function doNothing() { };
            options.onFailure = (options.onFailure) ? options.onFailure : function doNothing() { };
            options.async = ((options.async != null) && (options.async != undefined)) ? options.async : true;
        }
        //new Request.JSON(options).send()
        var Async = new AsyncRequestJSON();
        Async.Send(options);
    } catch (Error) { return Error; };
}

(function () {
    function _AsyncRequestJSON(standardOptions) {
        try {
            var privateParameters;
            var options;
            var xhr;
            var running;
            var status;

            function _initialize() {
                try {
                    privateParameters = new PrivateParameters(standardOptions);
                    var status = 0;
                    options = {
                        secure: true
                        , headers: { 'Accept': 'application/json', 'X-Request': 'JSON' }
                        , url: ''
		                , data: ''
                        , async: true
                		, format: false
                		, method: 'post'
                		, link: 'ignore'
                		, isSuccess: null
                		, emulation: true
                		, urlEncoded: true
                		, encoding: 'utf-8'
                		, evalScripts: false
                		, evalResponse: false
                		, noCache: false
                    };
                } catch (Error) { privateParameters.Events.onError(Error); }
            }

            _initialize();

            function _getXHR() {
                try {
                    try {
                        return new XMLHttpRequest();
                    } catch (Error) { privateParameters.Events.onError(Error); }
                    try {
                        return new ActiveXObject("Msxml2.DOMDocument.3.0");
                    } catch (Error) { privateParameters.Events.onError(Error); }
                    try {
                        return new ActiveXObject('MSXML2.XMLHTTP');
                    } catch (Error) { privateParameters.Events.onError(Error); }
                    try {
                        return new ActiveXObject('Microsoft.XMLHTTP');
                    } catch (Error) { privateParameters.Events.onError(Error); }
                } catch (Error) { privateParameters.Events.onError(Error); }
            }

            function _getEngine() {
                try {
                    presto = function () { return (!window.opera) ? false : ((arguments.callee.caller) ? 960 : ((document.getElementsByClassName) ? 950 : 925)); }
                    trident = function () { return (!window.ActiveXObject) ? false : ((window.XMLHttpRequest) ? ((document.querySelectorAll) ? 6 : 5) : 4); }
                    webkit = function () { return (navigator.taintEnabled) ? false : ((Browser.Features.xpath) ? ((Browser.Features.query) ? 525 : 420) : 419); }
                    gecko = function () { return (!document.getBoxObjectFor && window.mozInnerScreenX == null) ? false : ((document.getElementsByClassName) ? 19 : 18); }
                } catch (Error) { privateParameters.Events.onError(Error); }
            }

            function _wasSuccess() {
                try {
                    return ((status >= 200) && (status < 300));
                } catch (Error) { privateParameters.Events.onError(Error); }
            }

            function _onstatechange() {
                try {
                    if (xhr.readyState != 4 || !running) return;
                    running = false;
                    status = 0;
                    try {
                        status = xhr.status;
                    } catch (Error) { }

                    xhr.onreadystatechange = null;
                    if (_wasSuccess()) {
                        response = { text: xhr.responseText, xml: xhr.responseXML };
                        _success(response.text, response.xml);
                    } else {
                        response = { text: null, xml: null };
                        options.onFailure(response);
                    }
                } catch (Error) { privateParameters.Events.onError(Error); }
            }

            function _execute(text) {
                try {
                    if (!text) return text;
                    if (window.execScript) {
                        window.execScript(text);
                    } else {
                        var script = document.createElement('script');
                        script.setAttribute('type', 'text/javascript');
                        script[(Browser.Engine.webkit && Browser.Engine.version < 420) ? 'innerText' : 'text'] = text;
                        document.head.appendChild(script);
                        document.head.removeChild(script);
                    }
                    return text;
                } catch (Error) { privateParameters.Events.onError(Error); }
            }

            function _evalScripts(text) {
                if (options.evalResponse || (/(ecma|java)script/).test(_getHeader('Content-type'))) return _execute(text);
                return text.stripScripts(options.evalScripts);
            }

            function _getHeader(name) {
                try {
                    return xhr.getResponseHeader(name);
                } catch (Error) { privateParameters.Events.onError(Error); }
            }

            function _success(text) {
                //options.onSuccess(_evalScripts(text), xml);
                response.json = JSONDecode(text, options.secure);
                options.onSuccess(response.json, text);
            }

            function _send(sendOptions) {
                try {
                    var type = _getType(sendOptions);
                    if (sendOptions) for (var option in sendOptions) eval('options.' + option + '=sendOptions["' + option + '"]');
                    if (type == 'string' || type == 'element') options = { data: options };
                    xhr = _getXHR();
                    if (xhr) {
                        xhr.open(options.method.toUpperCase(), options.url, options.async);
                        running = true;
                        xhr.onreadystatechange = _onstatechange;
                        for (var key in options.headers) {
                            try {
                                xhr.setRequestHeader(key, options.headers[key]);
                            } catch (Error) { }
                        }
                        xhr.send(options.data);
                        if (!options.async) _onstatechange();
                    }

                } catch (Error) { privateParameters.Events.onError(Error); }
            }

            //Public members
            this.Send = function (options) {
                _send(options);
            }

        } catch (Error) { return Error; }
    }

    window.AsyncRequestJSON = function (options) { return new _AsyncRequestJSON(options); }

    var specialChars = { '\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"': '\\"', '\\': '\\\\' }

    function _replaceChars(chr) {
        return specialChars[chr] || '\\u00' + Math.floor(chr.charCodeAt() / 16).toString(16) + (chr.charCodeAt() % 16).toString(16);
    }

    function _getType(obj) {
        try {
            if (obj == undefined) return false;
            if (obj.nodeName) {
                switch (obj.nodeType) {
                    case 1: return 'element';
                    case 3: return (/\S/).test(obj.nodeValue) ? 'textnode' : 'whitespace';
                }
            } else if (typeof obj.length == 'number') {
                if (obj.callee) return 'arguments';
                else if (obj.item) return 'collection';
                else if (typeof (obj) != 'string') return 'array';
            }
            if (typeof (obj)) return (typeof (obj) == 'number' && !isFinite(obj)) ? false : typeof (obj);
            return typeof obj;
        } catch (Error) { }
    }

    function _JSONEncode(obj) {
        try {
            switch (_getType(obj)) {
                case 'string':
                    return '"' + obj.replace(/[\x00-\x1f\\"]/g, _replaceChars) + '"';
                case 'array':
                    var parse = '[';
                    for (var i = 0; i < obj.length; i++) parse += String(_JSONEncode(obj[i])) + ',';
                    parse = (parse.length > 1) ? parse.substring(0, parse.length - 1) : parse;
                    return (parse + ']');
                case 'object':
                    var string = [];
                    for (var key in obj) {
                        var json = _JSONEncode(obj[key]);
                        if (json) string.push(_JSONEncode(key) + ':' + json);
                    }
                    return '{' + string + '}';
                case 'number':
                case 'boolean':
                    return String(obj);
                case false:
                    return 'null';
            }
            return null;
        } catch (Error) { return Error; }
    }

    window.JSONEncode = function (obj) { return _JSONEncode(obj); }

    function _JSONDecode(string, secure) {
        try {
            if (_getType(string) != 'string' || !string.length) return null;
            if (secure && !(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(string.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''))) return null;
            return eval('(' + string + ')');
        } catch (Error) { return Error; }
    }

    window.JSONDecode = function (string, secure) { return _JSONDecode(string, secure); }
})();

/* /////////////////////////////////////////////////////////////////////////////// */

(function () {
    function _Browser() {
        try {
            this.IE = !!(window.attachEvent && !window.opera);
            this.Opera = !!window.opera;
            this.Chrome = navigator.userAgent.indexOf('AppleWebKit/') > -1; //WebKit
            this.Mozilla = navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1; //Mozilla
            this.MobileSafari = !!navigator.userAgent.match(/Apple.*Mobile.*Safari/);
            return this;
        } catch (Error) { }
    };
    window.Browser = new _Browser(); //function () {return _Browser();}
})();


/* /////////////////////////////////////////////////////////////////////////////// */

(function () {
    try {
        function _DBDataSet(options) {
            try {
                var tables;
                var privateParameters;
                var privateClasses;

                function _initialize(options) {
                    try {
                        tables = null;

                        privateParameters = new PrivateParameters(options);
                        privateParameters.Version.Class = 'DBDataSet';
                        privateClasses = new PrivateClasses({ "DataTable": DataTable });
                    }
                    catch (Error) { privateParameters.Events.onError(Error); }
                }

                function _refreshData(parameters) {
                    try {
                        var url = privateParameters.URL;
                        var options = {}; options.data = {};
                        options.data.DatabaseParameters = privateParameters.DatabaseParameters;
                        options.data.JSONFile = privateParameters.JSONFile;
                        for (var conParam in privateParameters.ConnectionParameters)
                            options[conParam] = privateParameters.ConnectionParameters[conParam];
                        if ((parameters) && (parameters.Version))
                            options.data.DatabaseParameters.QueryParameters = parameters.GetQueryParameters();
                        else options = (parameters) ? parameters : options;

                        options.data.Namespace = privateParameters.Version.Namespace;
                        options.data.Class = privateParameters.Version.Class;

                        options.onSuccess = function (requestData) {
                            try {
                                if ((requestData) && (!requestData.message)) {
                                    tables = requestData.tables;
                                    _redraw();
                                }
                            }
                            catch (Error) { privateParameters.Events.onError(Error); }
                        };
                        options.onFailure = function (arg) {
                            try { privateParameters.Events.onError(arg); }
                            catch (Error) { privateParameters.Events.onError(Error); }
                        };
                        RequestJSON(url, options);
                    }
                    catch (Error) { privateParameters.Events.onError(Error); }
                }

                function _redraw() {
                    try {
                        var tempData = new Object();
                        for (var dt in tables)
                            tempData[dt.toLowerCase()] = new privateClasses.DataTable(tables[dt]);
                        tables = tempData;

                        setTimeout(privateParameters.Events.onComplete, 1);
                    }
                    catch (Error) { privateParameters.Events.onError(Error); }
                }

                /*-----------------------------------------------------------------------*/
                /*------------------------------Instance it------------------------------*/
                /*-----------------------------------------------------------------------*/
                _initialize(options);
                /*-----------------------------------------------------------------------*/
                /*-----------------------------------------------------------------------*/
                /*-----------------------------------------------------------------------*/

                function _getData() {
                    var formatedData = new Array();
                    var iTable = 0;
                    try {
                        for (var dt in tables) {
                            formatedData[iTable] = tables[dt].GetMatrix();
                            iTable++;
                        }
                        return formatedData;
                    }
                    catch (Error) { privateParameters.Events.onError(Error); }
                    return null;
                }

                function _getDataJSON() {
                    var formatedData = new Object();
                    try {
                        for (var dt in tables)
                            formatedData[dt] = tables[dt].GetMatrixJSON();
                        return formatedData;
                    }
                    catch (Error) { privateParameters.Events.onError(Error); }
                    return null;
                }

                function _setData(newData) {
                    try {
                        tables = newData;
                        return true;
                    }
                    catch (Error) { privateParameters.Events.onError(Error); }
                    return false;
                }

                function _getTable(tableName) {
                    try {
                        return tables[tableName.toLowerCase()];
                    }
                    catch (Error) { privateParameters.Events.onError(Error); }
                }

                function _getTableMatrix(tableName) {
                    try {
                        return tables[tableName.toLowerCase()].GetMatrix();
                    }
                    catch (Error) { privateParameters.Events.onError(Error); }
                }

                function _getTableMatrixJSON(tableName) {
                    try {
                        return tables[tableName.toLowerCase()].GetMatrixJSON();
                    }
                    catch (Error) { privateParameters.Events.onError(Error); }
                }

                function _getTableRow(tableName, rowID) {
                    try {
                        return tables[tableName.toLowerCase()].GetRow(rowID);
                    }
                    catch (Error) { privateParameters.Events.onError(Error); }
                }

                function _getTableRowJSON(tableName, rowID) {
                    try {
                        return tables[tableName.toLowerCase()].GetRowJSON(rowID);
                    }
                    catch (Error) { privateParameters.Events.onError(Error); }
                }

                function _getTableCol(tableName, colID) {
                    try {
                        return tables[tableName.toLowerCase()].GetCol(colID);
                    }
                    catch (Error) { privateParameters.Events.onError(Error); }
                }

                function _getTableColID(tableName, colName) {
                    try {
                        return tables[tableName.toLowerCase()].GetColID(colName);
                    }
                    catch (Error) { privateParameters.Events.onError(Error); }
                }

                function _getTableCell(tableName, rowID, colID) {
                    try {
                        return tables[tableName.toLowerCase()].GetCell(rowID, colID);
                    }
                    catch (Error) { privateParameters.Events.onError(Error); }
                }

                function _getTableRowsCount(tableName) {
                    try {
                        return tables[tableName.toLowerCase()].GetRowsCount();
                    }
                    catch (Error) { privateParameters.Events.onError(Error); }
                }

                /*-------------------------*/
                /*-------Sub Classes-------*/
                /*-------------------------*/
                function DataTable() {
                    try {
                        function _DataTable(options) {
                            var privateParameters;

                            function _initialize(options) {
                                try {
                                    privateParameters = new PrivateParameters(options);
                                }
                                catch (Error) { privateParameters.Events.onError(Error); }
                            }

                            /*-----------------------------------------------------------------------*/
                            /*------------------------------Instance it------------------------------*/
                            /*-----------------------------------------------------------------------*/
                            _initialize(options);
                            /*-----------------------------------------------------------------------*/
                            /*-----------------------------------------------------------------------*/
                            /*-----------------------------------------------------------------------*/

                            function _getMatrix() {
                                var formatedMatrix = new Array();
                                try {
                                    var rowsCount = _getRowsCount();
                                    for (var iRow = 0; iRow < rowsCount; iRow++)
                                        formatedMatrix.push(privateParameters.Matrix.slice(iRow * privateParameters.ColumnsNamesList.length, iRow * privateParameters.ColumnsNamesList.length + privateParameters.ColumnsNamesList.length));
                                    return formatedMatrix;
                                }
                                catch (Error) { privateParameters.Events.onError(Error); }
                                return null;
                            }

                            function _getMatrixJSON() {
                                var formatedMatrixJSON = new Array();
                                try {
                                    var rowsCount = _getRowsCount();
                                    for (var iRow = 0; iRow < rowsCount; iRow++) {
                                        formatedMatrixJSON.push(new Array());
                                        for (var iCol = 0; iCol < privateParameters.ColumnsNamesList.length; iCol++)
                                            formatedMatrixJSON[iRow][privateParameters.ColumnsNamesList[iCol].toLowerCase()] = privateParameters.Matrix[iRow * privateParameters.ColumnsNamesList.length + iCol];
                                    }
                                    return formatedMatrixJSON;
                                }
                                catch (Error) { privateParameters.Events.onError(Error); }
                                return null;
                            }

                            function _getRow(rowID) {
                                try {
                                    return privateParameters.Matrix.slice(rowID * privateParameters.ColumnsNamesList.length, rowID * privateParameters.ColumnsNamesList.length + privateParameters.ColumnsNamesList.length);
                                }
                                catch (Error) { privateParameters.Events.onError(Error); }
                                return null;
                            }

                            function _getRowJSON(rowID) {
                                var rowJSON = new Object();
                                try {
                                    var row = _getRow(rowID);
                                    for (var iCol = 0; iCol < privateParameters.ColumnsNamesList.length; iCol++)
                                        rowJSON[privateParameters.ColumnsNamesList[iCol].toLowerCase()] = row[iCol];
                                    return rowJSON;
                                }
                                catch (Error) { privateParameters.Events.onError(Error); }
                                return null;
                            }

                            function _getCol(colID) {
                                var col = new Array();
                                try {
                                    var rowsCount = _getRowsCount();
                                    for (var iRow = 0; iRow < rowsCount; iRow++)
                                        col.push(privateParameters.Matrix[colID + iRow * privateParameters.ColumnsNamesList.length]);
                                    return col;
                                }
                                catch (Error) { privateParameters.Events.onError(Error); }
                                return null;
                            }

                            function _getColID(colName) {
                                try {
                                    for (var iCol = 0; iCol < privateParameters.ColumnsNamesList.length; iCol++)
                                        if (colName.toUpperCase() == privateParameters.ColumnsNamesList[iCol].toUpperCase())
                                            return iCol;
                                }
                                catch (Error) { privateParameters.Events.onError(Error); }
                                return -1;
                            }

                            function _getCell(rowID, colID) {
                                try {
                                    if ((colID >= 0) && (colID < privateParameters.ColumnsNamesList.length))
                                        return privateParameters.Matrix[rowID * privateParameters.ColumnsNamesList.length + colID];
                                }
                                catch (Error) { privateParameters.Events.onError(Error); }
                                return null;
                            }

                            function _getRowsCount() {
                                try {
                                    var rowsCount = parseInt(privateParameters.Matrix.length / privateParameters.ColumnsNamesList.length);
                                    if (privateParameters.Matrix.length % privateParameters.ColumnsNamesList.length) rowsCount++;
                                    return rowsCount;
                                }
                                catch (Error) { privateParameters.Events.onError(Error); }
                                return 0;
                            }

                            /*-------------------------*/
                            /*-------Public zone-------*/
                            /*-------------------------*/
                            this.GetMatrix = function () {
                                return _getMatrix();
                            };
                            this.GetMatrixJSON = function () {
                                return _getMatrixJSON();
                            };
                            this.GetRow = function (rowID) {
                                return _getRow(rowID);
                            };
                            this.GetRowJSON = function (rowID) {
                                return _getRowJSON(rowID);
                            };
                            this.GetCol = function (colID) {
                                return _getCol(colID);
                            };
                            this.GetColID = function (colName) {
                                return _getColID(colName);
                            };
                            this.GetCell = function (rowID, colID) {
                                return _getCell(rowID, colID);
                            };
                            this.GetRowsCount = function () {
                                return _getRowsCount();
                            };
                        }

                        return function (instanceOptions) { return new _DataTable(instanceOptions); };
                    }
                    catch (Error) { privateParameters.Events.onError(Error); }
                }

                /*-------------------------*/
                /*-------Public zone-------*/
                /*-------------------------*/
                this.RefreshData = function (tables) {
                    _refreshData(tables);
                }

                this.GetData = function () {
                    return _getData();
                };
                this.GetDataJSON = function () {
                    return _getDataJSON();
                };
                this.GetTable = function (tableName) {
                    return _getTable(tableName);
                };
                this.GetTableMatrix = function (tableName) {
                    return _getTableMatrix(tableName);
                };
                this.GetTableMatrixJSON = function (tableName) {
                    return _getTableMatrixJSON(tableName);
                };
                this.GetTableRow = function (tableName, rowID) {
                    return _getTableRow(tableName, rowID);
                };
                this.getTableRowJSON = function (tableName, rowID) {
                    return _getTableRowJSON(tableName, rowID);
                };
                this.GetTableCol = function (tableName, colID) {
                    return _getTableCol(tableName, colID);
                };
                this.GetTableColID = function (tableName, colName) {
                    return _getTableColID(tableName, colName);
                };
                this.GetTableCell = function (tableName, rowID, colID) {
                    return _getTableCell(tableName, rowID, colID);
                };
                this.GetTableRowsCount = function (tableName) {
                    return _getTableRowsCount(tableName);
                };
            }
            catch (Error) { privateParameters.Events.onError(Error); }
        }

        window.DBDataSet = function (instanceOptions) { return new _DBDataSet(instanceOptions); };
    }
    catch (Error) { window.status = Error.message; }
})();